对于java.beans.PersistenceDelegate的实例源码感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解java.beans.introspection,并且为您提供关于a
对于java.beans.PersistenceDelegate的实例源码感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解java.beans.introspection,并且为您提供关于android.arch.persistence.room.Delete的实例源码、java.beans.DefaultPersistenceDelegate的实例源码、javax.management.MBeanServerDelegate的实例源码、javax.persistence.AttributeOverride的实例源码的宝贵知识。
本文目录一览:- java.beans.PersistenceDelegate的实例源码(java.beans.introspection)
- android.arch.persistence.room.Delete的实例源码
- java.beans.DefaultPersistenceDelegate的实例源码
- javax.management.MBeanServerDelegate的实例源码
- javax.persistence.AttributeOverride的实例源码
java.beans.PersistenceDelegate的实例源码(java.beans.introspection)
private static void setPersistenceDelegates(XMLEncoder encoder,Class<?>[] types) { if (types != null && types.length > 0) { PersistenceDelegate persistenceDelegate = new EnumPersistenceDelegate(); for (int i = 0; i < types.length; i++) { encoder.setPersistenceDelegate(types[i],persistenceDelegate); } } // Handle "BiGDecimal" manually (has no default constructor) encoder.setPersistenceDelegate(BigDecimal.class,new BigDecimalPersistenceDelegate()); encoder.setPersistenceDelegate(byte[].class,new ByteArrayPersistenceDelegate()); encoder.setPersistenceDelegate(UUID.class,new UUIDDelegate()); }
public static void main(String[] args) { XMLEncoder encoder = new XMLEncoder(System.out); encoder.setPersistenceDelegate(Test4646747.class,new MyPersistenceDelegate()); // WARNING: This can eat up a lot of memory Object[] obs = new Object[10000]; while (obs != null) { try { obs = new Object[obs.length + obs.length / 3]; } catch (OutOfMemoryError error) { obs = null; } } PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class); if (!(pd instanceof MyPersistenceDelegate)) throw new Error("persistence delegate has been lost"); }
public static void main(String[] args) { XMLEncoder encoder = new XMLEncoder(System.out); encoder.setPersistenceDelegate(Test4646747.class,new MyPersistenceDelegate()); // WARNING: This can eat up a lot of memory Object[] obs = new Object[10000]; while (obs != null) { try { obs = new Object[obs.length + obs.length / 3]; } catch (OutOfMemoryError error) { obs = null; } } PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class); if (!(pd instanceof MyPersistenceDelegate)) throw new Error("persistence delegate has been lost"); }
public static void main(String[] args) { XMLEncoder encoder = new XMLEncoder(System.out); encoder.setPersistenceDelegate(Test4646747.class,new MyPersistenceDelegate()); // WARNING: This can eat up a lot of memory Object[] obs = new Object[10000]; while (obs != null) { try { obs = new Object[obs.length + obs.length / 3]; } catch (OutOfMemoryError error) { obs = null; } } PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class); if (!(pd instanceof MyPersistenceDelegate)) throw new Error("persistence delegate has been lost"); }
public static void main(String[] args) { XMLEncoder encoder = new XMLEncoder(System.out); encoder.setPersistenceDelegate(Test4646747.class,new MyPersistenceDelegate()); // WARNING: This can eat up a lot of memory Object[] obs = new Object[10000]; while (obs != null) { try { obs = new Object[obs.length + obs.length / 3]; } catch (OutOfMemoryError error) { obs = null; } } PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class); if (!(pd instanceof MyPersistenceDelegate)) throw new Error("persistence delegate has been lost"); }
public static void main(String[] args) { XMLEncoder encoder = new XMLEncoder(System.out); encoder.setPersistenceDelegate(Test4646747.class,new MyPersistenceDelegate()); // WARNING: This can eat up a lot of memory Object[] obs = new Object[10000]; while (obs != null) { try { obs = new Object[obs.length + obs.length / 3]; } catch (OutOfMemoryError error) { obs = null; } } PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class); if (!(pd instanceof MyPersistenceDelegate)) throw new Error("persistence delegate has been lost"); }
private static void setPersistenceDelegates(XMLEncoder encoder,new UUIDDelegate()); }
public static void main(String[] args) { XMLEncoder encoder = new XMLEncoder(System.out); encoder.setPersistenceDelegate(Test4646747.class,new MyPersistenceDelegate()); // WARNING: This can eat up a lot of memory Object[] obs = new Object[10000]; while (obs != null) { try { obs = new Object[obs.length + obs.length / 3]; } catch (OutOfMemoryError error) { obs = null; } } PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class); if (!(pd instanceof MyPersistenceDelegate)) throw new Error("persistence delegate has been lost"); }
public static void main(String[] args) { XMLEncoder encoder = new XMLEncoder(System.out); encoder.setPersistenceDelegate(Test4646747.class,new MyPersistenceDelegate()); // WARNING: This can eat up a lot of memory Object[] obs = new Object[10000]; while (obs != null) { try { obs = new Object[obs.length + obs.length / 3]; } catch (OutOfMemoryError error) { obs = null; } } PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class); if (!(pd instanceof MyPersistenceDelegate)) throw new Error("persistence delegate has been lost"); }
public static void main(String[] args) { XMLEncoder encoder = new XMLEncoder(System.out); encoder.setPersistenceDelegate(Test4646747.class,new MyPersistenceDelegate()); // WARNING: This can eat up a lot of memory Object[] obs = new Object[10000]; while (obs != null) { try { obs = new Object[obs.length + obs.length / 3]; } catch (OutOfMemoryError error) { obs = null; } } PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class); if (!(pd instanceof MyPersistenceDelegate)) throw new Error("persistence delegate has been lost"); }
public static void main(String[] args) { XMLEncoder encoder = new XMLEncoder(System.out); encoder.setPersistenceDelegate(Test4646747.class,new MyPersistenceDelegate()); // WARNING: This can eat up a lot of memory Object[] obs = new Object[10000]; while (obs != null) { try { obs = new Object[obs.length + obs.length / 3]; } catch (OutOfMemoryError error) { obs = null; } } PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class); if (!(pd instanceof MyPersistenceDelegate)) throw new Error("persistence delegate has been lost"); }
public static void main(String[] args) { XMLEncoder encoder = new XMLEncoder(System.out); encoder.setPersistenceDelegate(Test4646747.class,new MyPersistenceDelegate()); // WARNING: This can eat up a lot of memory Object[] obs = new Object[10000]; while (obs != null) { try { obs = new Object[obs.length + obs.length / 3]; } catch (OutOfMemoryError error) { obs = null; } } PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class); if (!(pd instanceof MyPersistenceDelegate)) throw new Error("persistence delegate has been lost"); }
private void recordCall(Object param) { StackTraceElement[] eles = (new Throwable()).getStackTrace(); int i = 0; // skip Throwable.init() while (eles[i].getClassName().equals("java.lang.Throwable")) { i++; } // skip calls from MockEncoder while (eles[i].getClassName().equals(MockEncoder.class.getName())) { i++; } // skip calls from DefaultPersistenceDelegate & PersistenceDelegate while (eles[i].getClassName().equals( DefaultPersistenceDelegate.class.getName()) || eles[i].getClassName().equals( PersistenceDelegate.class.getName())) { i++; } if (i > 2 && eles[++i].getClassName().equals( DefaultPersistenceDelegateTest.class.getName())) { CallVerificationStack.getInstance().push(param); } }
public void testGetPersistenceDelegate_Default() { Encoder enc = new Encoder(); Encoder enc2 = new Encoder(); PersistenceDelegate pd1 = enc.getPersistenceDelegate(SampleBean.class); assertTrue(pd1 instanceof DefaultPersistenceDelegate); PersistenceDelegate pd2 = enc.getPersistenceDelegate(SampleBean.class); assertTrue(pd2 instanceof DefaultPersistenceDelegate); PersistenceDelegate pd3 = enc2 .getPersistenceDelegate(MockBean4Codec.class); assertTrue(pd3 instanceof DefaultPersistenceDelegate); assertSame(pd1,pd2); assertSame(pd1,pd3); }
public static void main(String[] args) { XMLEncoder encoder = new XMLEncoder(System.out); encoder.setPersistenceDelegate(Test4646747.class,new MyPersistenceDelegate()); // WARNING: This can eat up a lot of memory Object[] obs = new Object[10000]; while (obs != null) { try { obs = new Object[obs.length + obs.length / 3]; } catch (OutOfMemoryError error) { obs = null; } } PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class); if (!(pd instanceof MyPersistenceDelegate)) throw new Error("persistence delegate has been lost"); }
public static void main(String[] args) { XMLEncoder encoder = new XMLEncoder(System.out); encoder.setPersistenceDelegate(Test4646747.class,new MyPersistenceDelegate()); // WARNING: This can eat up a lot of memory Object[] obs = new Object[10000]; while (obs != null) { try { obs = new Object[obs.length + obs.length / 3]; } catch (OutOfMemoryError error) { obs = null; } } PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class); if (!(pd instanceof MyPersistenceDelegate)) throw new Error("persistence delegate has been lost"); }
private void recordCall(Object param) { StackTraceElement[] eles = (new Throwable()).getStackTrace(); int i = 0; // skip Throwable.init() while (eles[i].getClassName().equals("java.lang.Throwable")) { i++; } // skip calls from MockEncoder while (eles[i].getClassName().equals(MockEncoder.class.getName())) { i++; } // skip calls from DefaultPersistenceDelegate & PersistenceDelegate while (eles[i].getClassName().equals( DefaultPersistenceDelegate.class.getName()) || eles[i].getClassName().equals( PersistenceDelegate.class.getName())) { i++; } if (i > 2 && eles[++i].getClassName().equals( DefaultPersistenceDelegateTest.class.getName())) { CallVerificationStack.getInstance().push(param); } }
public void testGetPersistenceDelegate_Default() { Encoder enc = new Encoder(); Encoder enc2 = new Encoder(); PersistenceDelegate pd1 = enc.getPersistenceDelegate(SampleBean.class); assertTrue(pd1 instanceof DefaultPersistenceDelegate); PersistenceDelegate pd2 = enc.getPersistenceDelegate(SampleBean.class); assertTrue(pd2 instanceof DefaultPersistenceDelegate); PersistenceDelegate pd3 = enc2 .getPersistenceDelegate(MockBean4Codec.class); assertTrue(pd3 instanceof DefaultPersistenceDelegate); assertSame(pd1,pd3); }
public static void main(String[] args) { XMLEncoder encoder = new XMLEncoder(System.out); encoder.setPersistenceDelegate(Test4646747.class,new MyPersistenceDelegate()); // WARNING: This can eat up a lot of memory Object[] obs = new Object[10000]; while (obs != null) { try { obs = new Object[obs.length + obs.length / 3]; } catch (OutOfMemoryError error) { obs = null; } } PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class); if (!(pd instanceof MyPersistenceDelegate)) throw new Error("persistence delegate has been lost"); }
public void register(Class<?> type,PersistenceDelegate delegate) { synchronized (this.registry) { if (delegate != null) { this.registry.put(type,delegate); } else { this.registry.remove(type); } } }
@Override public PersistenceDelegate find(Class<?> type) { PersistenceDelegate delegate; synchronized (this.registry) { delegate = this.registry.get(type); } return (delegate != null) ? delegate : super.find(type); }
public void register(Class<?> type,delegate); } else { this.registry.remove(type); } } }
@Override public PersistenceDelegate find(Class<?> type) { PersistenceDelegate delegate; synchronized (this.registry) { delegate = this.registry.get(type); } return (delegate != null) ? delegate : super.find(type); }
private static void test(Class<?> type,Class<? extends PersistenceDelegate> expected) { PersistenceDelegate actual = ENCODER.getPersistenceDelegate(type); if ((actual == null) && (expected != null)) { throw new Error("expected delegate is not found"); } if ((actual != null) && !actual.getClass().equals(expected)) { throw new Error("found unexpected delegate"); } }
protected void initialize(XMLEncoder encoder) { encoder.setPersistenceDelegate(Container.class,new PersistenceDelegate() { protected Expression instantiate(Object oldInstance,Encoder out) { Container container = (Container) oldInstance; Component component = container.getComponent(); return new Expression(container,component,"create",new Object[] {component}); } }); }
private static void test(Class<?> type,PersistenceDelegate pd) { Encoder encoder1 = new Encoder(); Encoder encoder2 = new XMLEncoder(System.out); PersistenceDelegate pd1 = encoder1.getPersistenceDelegate(type); PersistenceDelegate pd2 = encoder2.getPersistenceDelegate(type); encoder1.setPersistenceDelegate(type,pd); if (pd1 == encoder1.getPersistenceDelegate(type)) throw new Error("first persistence delegate is not changed"); if (pd2 != encoder2.getPersistenceDelegate(type)) throw new Error("second persistence delegate is changed"); }
public void register(Class<?> type,delegate); } else { this.registry.remove(type); } } }
@Override public PersistenceDelegate find(Class<?> type) { PersistenceDelegate delegate; synchronized (this.registry) { delegate = this.registry.get(type); } return (delegate != null) ? delegate : super.find(type); }
private static void test(Class<?> type,Class<? extends PersistenceDelegate> expected) { PersistenceDelegate actual = ENCODER.getPersistenceDelegate(type); if ((actual == null) && (expected != null)) { throw new Error("expected delegate is not found"); } if ((actual != null) && !actual.getClass().equals(expected)) { throw new Error("found unexpected delegate"); } }
protected void initialize(XMLEncoder encoder) { encoder.setPersistenceDelegate(Container.class,new Object[] {component}); } }); }
private static void test(Class<?> type,pd); if (pd1 == encoder1.getPersistenceDelegate(type)) throw new Error("first persistence delegate is not changed"); if (pd2 != encoder2.getPersistenceDelegate(type)) throw new Error("second persistence delegate is changed"); }
public void register(Class<?> type,delegate); } else { this.registry.remove(type); } } }
@Override public PersistenceDelegate find(Class<?> type) { PersistenceDelegate delegate; synchronized (this.registry) { delegate = this.registry.get(type); } return (delegate != null) ? delegate : super.find(type); }
private static void test(Class<?> type,Class<? extends PersistenceDelegate> expected) { PersistenceDelegate actual = ENCODER.getPersistenceDelegate(type); if ((actual == null) && (expected != null)) { throw new Error("expected delegate is not found"); } if ((actual != null) && !actual.getClass().equals(expected)) { throw new Error("found unexpected delegate"); } }
protected void initialize(XMLEncoder encoder) { encoder.setPersistenceDelegate(Container.class,new Object[] {component}); } }); }
private static void test(Class<?> type,pd); if (pd1 == encoder1.getPersistenceDelegate(type)) throw new Error("first persistence delegate is not changed"); if (pd2 != encoder2.getPersistenceDelegate(type)) throw new Error("second persistence delegate is changed"); }
public void register(Class<?> type,delegate); } else { this.registry.remove(type); } } }
@Override public PersistenceDelegate find(Class<?> type) { PersistenceDelegate delegate; synchronized (this.registry) { delegate = this.registry.get(type); } return (delegate != null) ? delegate : super.find(type); }
android.arch.persistence.room.Delete的实例源码
@Delete int delete(Product product);
@Delete void delete(FeedEntry FeedEntry);
@Delete void delete(List<Ride> rides);
@Delete void deleteall(LocationInfo... locationInfoList);
@Delete void delete(UploadItem... uploadItem);
@Delete void deleteLogcatItem(LogcatItem item);
@Delete void deleteRestoredFolder(Sync syncedFolder);
@Delete public void deleteLEDEntities(LEDEntity ...entities);
@Delete void delete(Book book);
@Delete void delete(Product product);
@Delete void delete(ClaimItem item);
@Delete void delete(Attachment attachment);
@Delete void delete(ZhihuDailyNewsQuestion item);
@Delete void delete(GuokrHandpickNewsResult item);
@Delete void delete(DoubanMomentNewsPosts item);
@Delete void delete(GuokrHandpickContentResult item);
@Delete void delete(DoubanMomentContent content);
@Delete void delete(ZhihuDailyContent content);
@Delete void delete( EosAccount account);
@Delete void deleteUser(User user);
@Delete void deleteUsers(User user1,User user2);
@Delete void delete(DocumentEntity... documents);
@Delete void delete(Note note);
@Delete void delete(User user);
@Delete public void deletePerson(Person person);
@Delete public void delete(score score);
@Delete void deleteOne(QuoteDbModel quoteDbModel);
@Delete void deleteUserLocation(UserLocation userLocation);
java.beans.DefaultPersistenceDelegate的实例源码
static void test(AbstractTest object) { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output); encoder.setPersistenceDelegate( object.getClass(),new DefaultPersistenceDelegate(new String[] {"value"})); encoder.writeObject(object); encoder.close(); System.out.print(output); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); AbstractTest result = (AbstractTest) decoder.readobject(); decoder.close(); if (object.getValue() != result.getValue()) throw new Error("Should be " + object); }
static void test(AbstractTest object) { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output); encoder.setPersistenceDelegate( object.getClass(),new DefaultPersistenceDelegate(new String[] {"value"})); encoder.writeObject(object); encoder.close(); System.out.print(output); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); AbstractTest result = (AbstractTest) decoder.readobject(); decoder.close(); if (object.getValue() != result.getValue()) throw new Error("Should be " + object); }
static void test(AbstractTest object) { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output); encoder.setPersistenceDelegate( object.getClass(),new DefaultPersistenceDelegate(new String[] {"value"})); encoder.writeObject(object); encoder.close(); System.out.print(output); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); AbstractTest result = (AbstractTest) decoder.readobject(); decoder.close(); if (object.getValue() != result.getValue()) throw new Error("Should be " + object); }
static void test(AbstractTest object) { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output); encoder.setPersistenceDelegate( object.getClass(),new DefaultPersistenceDelegate(new String[] {"value"})); encoder.writeObject(object); encoder.close(); System.out.print(output); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); AbstractTest result = (AbstractTest) decoder.readobject(); decoder.close(); if (object.getValue() != result.getValue()) throw new Error("Should be " + object); }
static void test(AbstractTest object) { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output); encoder.setPersistenceDelegate( object.getClass(),new DefaultPersistenceDelegate(new String[] {"value"})); encoder.writeObject(object); encoder.close(); System.out.print(output); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); AbstractTest result = (AbstractTest) decoder.readobject(); decoder.close(); if (object.getValue() != result.getValue()) throw new Error("Should be " + object); }
/** * Configure the serialization of the File. */ @Override protected void setupXML(XMLEncoder enc) { super.setupXML(enc); PropertyDescriptor[] pdArr; try { pdArr = Introspector.getBeanInfo(VirtualFileSystemFile.class) .getPropertyDescriptors(); } catch (IntrospectionException e) { logger.error("I don't kNow what to do here",e); throw new RuntimeException(e); } for (PropertyDescriptor pd : pdArr) { // logger.debug("PropertyDescriptor - VirtualFileSystemFile - " // + pd.getdisplayName()); if (transientListFile.contains(pd.getName())) { pd.setValue("transient",Boolean.TRUE); } } // needed to create a VFSFile object during unserialization enc.setPersistenceDelegate(VirtualFileSystemFile.class,new DefaultPersistenceDelegate(new String[] { "username","group","size","slaves" })); }
@Override protected void setupXML(XMLEncoder enc) { super.setupXML(enc); PropertyDescriptor[] pdArr; try { pdArr = Introspector.getBeanInfo(VirtualFileSystemLink.class) .getPropertyDescriptors(); } catch (IntrospectionException e) { logger.error("I don't kNow what to do here",e); throw new RuntimeException(e); } for (int x = 0; x < pdArr.length; x++) { // logger.debug("PropertyDescriptor - VirtualFileSystemLink - " // + pdArr[x].getdisplayName()); if (transientListLink.contains(pdArr[x].getName())) { pdArr[x].setValue("transient",Boolean.TRUE); } } enc.setPersistenceDelegate(VirtualFileSystemLink.class,"linkPath" })); }
/** * Sets up the XMLEnconder. */ public XMLEncoder getXMLEncoder(OutputStream out) { XMLEncoder e = new XMLEncoder(out); e.setExceptionListener(new ExceptionListener() { public void exceptionThrown(Exception e1) { logger.error("",e1); } }); e.setPersistenceDelegate(BeanUser.class,new DefaultPersistenceDelegate(new String[] { "name" })); e.setPersistenceDelegate(Key.class,new DefaultPersistenceDelegate( new String[] { "owner","key" })); e.setPersistenceDelegate(HostMask.class,new DefaultPersistenceDelegate(new String[] { "mask" })); return e; }
static void test(AbstractTest object) { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output); encoder.setPersistenceDelegate( object.getClass(),new DefaultPersistenceDelegate(new String[] {"value"})); encoder.writeObject(object); encoder.close(); System.out.print(output); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); AbstractTest result = (AbstractTest) decoder.readobject(); decoder.close(); if (object.getValue() != result.getValue()) throw new Error("Should be " + object); }
static void test(AbstractTest object) { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output); encoder.setPersistenceDelegate( object.getClass(),new DefaultPersistenceDelegate(new String[] {"value"})); encoder.writeObject(object); encoder.close(); System.out.print(output); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); AbstractTest result = (AbstractTest) decoder.readobject(); decoder.close(); if (object.getValue() != result.getValue()) throw new Error("Should be " + object); }
static void test(AbstractTest object) { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output); encoder.setPersistenceDelegate( object.getClass(),new DefaultPersistenceDelegate(new String[] {"value"})); encoder.writeObject(object); encoder.close(); System.out.print(output); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); AbstractTest result = (AbstractTest) decoder.readobject(); decoder.close(); if (object.getValue() != result.getValue()) throw new Error("Should be " + object); }
static void test(AbstractTest object) { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output); encoder.setPersistenceDelegate( object.getClass(),new DefaultPersistenceDelegate(new String[] {"value"})); encoder.writeObject(object); encoder.close(); System.out.print(output); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); AbstractTest result = (AbstractTest) decoder.readobject(); decoder.close(); if (object.getValue() != result.getValue()) throw new Error("Should be " + object); }
static void test(AbstractTest object) { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output); encoder.setPersistenceDelegate( object.getClass(),new DefaultPersistenceDelegate(new String[] {"value"})); encoder.writeObject(object); encoder.close(); System.out.print(output); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); AbstractTest result = (AbstractTest) decoder.readobject(); decoder.close(); if (object.getValue() != result.getValue()) throw new Error("Should be " + object); }
private void recordCall(Object param) { StackTraceElement[] eles = (new Throwable()).getStackTrace(); int i = 0; // skip Throwable.init() while (eles[i].getClassName().equals("java.lang.Throwable")) { i++; } // skip calls from MockEncoder while (eles[i].getClassName().equals(MockEncoder.class.getName())) { i++; } // skip calls from DefaultPersistenceDelegate & PersistenceDelegate while (eles[i].getClassName().equals( DefaultPersistenceDelegate.class.getName()) || eles[i].getClassName().equals( PersistenceDelegate.class.getName())) { i++; } if (i > 2 && eles[++i].getClassName().equals( DefaultPersistenceDelegateTest.class.getName())) { CallVerificationStack.getInstance().push(param); } }
public void testGetPersistenceDelegate_Default() { Encoder enc = new Encoder(); Encoder enc2 = new Encoder(); PersistenceDelegate pd1 = enc.getPersistenceDelegate(SampleBean.class); assertTrue(pd1 instanceof DefaultPersistenceDelegate); PersistenceDelegate pd2 = enc.getPersistenceDelegate(SampleBean.class); assertTrue(pd2 instanceof DefaultPersistenceDelegate); PersistenceDelegate pd3 = enc2 .getPersistenceDelegate(MockBean4Codec.class); assertTrue(pd3 instanceof DefaultPersistenceDelegate); assertSame(pd1,pd2); assertSame(pd1,pd3); }
static void test(AbstractTest object) { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output); encoder.setPersistenceDelegate( object.getClass(),new DefaultPersistenceDelegate(new String[] {"value"})); encoder.writeObject(object); encoder.close(); System.out.print(output); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); AbstractTest result = (AbstractTest) decoder.readobject(); decoder.close(); if (object.getValue() != result.getValue()) throw new Error("Should be " + object); }
static void test(AbstractTest object) { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output); encoder.setPersistenceDelegate( object.getClass(),new DefaultPersistenceDelegate(new String[] {"value"})); encoder.writeObject(object); encoder.close(); System.out.print(output); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); AbstractTest result = (AbstractTest) decoder.readobject(); decoder.close(); if (object.getValue() != result.getValue()) throw new Error("Should be " + object); }
private void recordCall(Object param) { StackTraceElement[] eles = (new Throwable()).getStackTrace(); int i = 0; // skip Throwable.init() while (eles[i].getClassName().equals("java.lang.Throwable")) { i++; } // skip calls from MockEncoder while (eles[i].getClassName().equals(MockEncoder.class.getName())) { i++; } // skip calls from DefaultPersistenceDelegate & PersistenceDelegate while (eles[i].getClassName().equals( DefaultPersistenceDelegate.class.getName()) || eles[i].getClassName().equals( PersistenceDelegate.class.getName())) { i++; } if (i > 2 && eles[++i].getClassName().equals( DefaultPersistenceDelegateTest.class.getName())) { CallVerificationStack.getInstance().push(param); } }
public void testGetPersistenceDelegate_Default() { Encoder enc = new Encoder(); Encoder enc2 = new Encoder(); PersistenceDelegate pd1 = enc.getPersistenceDelegate(SampleBean.class); assertTrue(pd1 instanceof DefaultPersistenceDelegate); PersistenceDelegate pd2 = enc.getPersistenceDelegate(SampleBean.class); assertTrue(pd2 instanceof DefaultPersistenceDelegate); PersistenceDelegate pd3 = enc2 .getPersistenceDelegate(MockBean4Codec.class); assertTrue(pd3 instanceof DefaultPersistenceDelegate); assertSame(pd1,pd3); }
static void test(AbstractTest object) { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output); encoder.setPersistenceDelegate( object.getClass(),new DefaultPersistenceDelegate(new String[] {"value"})); encoder.writeObject(object); encoder.close(); System.out.print(output); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); AbstractTest result = (AbstractTest) decoder.readobject(); decoder.close(); if (object.getValue() != result.getValue()) throw new Error("Should be " + object); }
/** * Configure the serialization of the File. */ @Override protected void setupXML(XMLEncoder enc) { super.setupXML(enc); PropertyDescriptor[] pdArr; try { pdArr = Introspector.getBeanInfo(VirtualFileSystemFile.class) .getPropertyDescriptors(); } catch (IntrospectionException e) { logger.error("I don't kNow what to do here",e); throw new RuntimeException(e); } for (int x = 0; x < pdArr.length; x++) { // logger.debug("PropertyDescriptor - VirtualFileSystemFile - " // + pdArr[x].getdisplayName()); if (transientListFile.contains(pdArr[x].getName())) { pdArr[x].setValue("transient","slaves" })); }
@Override protected void setupXML(XMLEncoder enc) { super.setupXML(enc); PropertyDescriptor[] pdArr; try { pdArr = Introspector.getBeanInfo(VirtualFileSystemLink.class) .getPropertyDescriptors(); } catch (IntrospectionException e) { logger.error("I don't kNow what to do here","linkPath" })); }
/** * Sets up the XMLEnconder. */ public XMLEncoder getXMLEncoder(OutputStream out) { XMLEncoder e = new XMLEncoder(out); e.setExceptionListener(new ExceptionListener() { public void exceptionThrown(Exception e1) { logger.error("",new DefaultPersistenceDelegate(new String[] { "mask" })); return e; }
/** * Serializes the TreeMap. * * @throws IOException */ public void commit() throws IOException { saveClassLoader(); XMLEncoder enc = null; try { switchClassLoaders(); enc = new XMLEncoder(new SafeFileOutputStream(nukeFile)); enc.setExceptionListener(new ExceptionListener() { public void exceptionThrown(Exception e) { logger.error(e,e); } }); enc.setPersistenceDelegate(LRUMap.class,new DefaultPersistenceDelegate(new String[] { "maxSize" } )); enc.writeObject(_nukes); } catch (IOException ex) { throw new IOException(ex.getMessage()); } finally { if (enc != null) enc.close(); } setPrevIoUsClassLoader(); }
public static void main(String[] args) throws InterruptedException { Class<?> type = TestPersistenceDelegate.class; test(type,DefaultPersistenceDelegate.class); ENCODER.setPersistenceDelegate(type,new BeanPersistenceDelegate()); test(type,BeanPersistenceDelegate.class); ENCODER.setPersistenceDelegate(type,null); test(type,DefaultPersistenceDelegate.class); // the following tests fails on prevIoUs build test(Bean.class,BeanPersistenceDelegate.class); test(BeanPersistenceDelegate.class,BeanPersistenceDelegate.class); }
protected void initialize(XMLEncoder encoder) { encoder.setPersistenceDelegate( OuterClass.InnerClass.class,new DefaultPersistenceDelegate() { protected Expression instantiate(Object oldInstance,Encoder out) { OuterClass.InnerClass inner = (OuterClass.InnerClass) oldInstance; OuterClass outer = inner.getouter(); return new Expression(inner,outer,"getInner",new Object[0]); } } ); }
protected void initialize(XMLEncoder encoder) { encoder.setPersistenceDelegate(C.class,new DefaultPersistenceDelegate() { protected Expression instantiate(Object oldInstance,Encoder out) { C c = (C) oldInstance; return new Expression(c,c.getX(),"createC",new Object[] {}); } }); }
public static void main(String[] args) throws InterruptedException { Class<?> type = TestPersistenceDelegate.class; test(type,BeanPersistenceDelegate.class); }
protected void initialize(XMLEncoder encoder) { encoder.setPersistenceDelegate( OuterClass.InnerClass.class,new Object[0]); } } ); }
protected void initialize(XMLEncoder encoder) { encoder.setPersistenceDelegate(C.class,new Object[] {}); } }); }
public static void main(String[] args) throws InterruptedException { Class<?> type = TestPersistenceDelegate.class; test(type,BeanPersistenceDelegate.class); }
protected void initialize(XMLEncoder encoder) { encoder.setPersistenceDelegate( OuterClass.InnerClass.class,new Object[0]); } } ); }
protected void initialize(XMLEncoder encoder) { encoder.setPersistenceDelegate(C.class,new Object[] {}); } }); }
public static void main(String[] args) throws InterruptedException { Class<?> type = TestPersistenceDelegate.class; test(type,BeanPersistenceDelegate.class); }
protected void initialize(XMLEncoder encoder) { encoder.setPersistenceDelegate( OuterClass.InnerClass.class,new Object[0]); } } ); }
javax.management.MBeanServerDelegate的实例源码
/** * Creates a DefaultMBeanServerInterceptor with the specified * repository instance. * <p>Do not forget to call <code>initialize(outer,delegate)</code> * before using this object. * @param outer A pointer to the MBeanServer object that must be * passed to the MBeans when invoking their * {@link javax.management.MBeanRegistration} interface. * @param delegate A pointer to the MBeanServerDelegate associated * with the new MBeanServer. The new MBeanServer must register * this MBean in its MBean repository. * @param instantiator The MBeanInstantiator that will be used to * instantiate MBeans and take care of class loading issues. * @param repository The repository to use for this MBeanServer. */ public DefaultMBeanServerInterceptor(MBeanServer outer,MBeanServerDelegate delegate,MBeanInstantiator instantiator,Repository repository) { if (outer == null) throw new IllegalArgumentException("outer MBeanServer cannot be null"); if (delegate == null) throw new IllegalArgumentException("MBeanServerDelegate cannot be null"); if (instantiator == null) throw new IllegalArgumentException("MBeanInstantiator cannot be null"); if (repository == null) throw new IllegalArgumentException("Repository cannot be null"); this.server = outer; this.delegate = delegate; this.instantiator = instantiator; this.repository = repository; this.domain = repository.getDefaultDomain(); }
/** * Sends an MBeanServerNotifications with the specified type for the * MBean with the specified ObjectName */ private void sendNotification(String NotifType,ObjectName name) { // ------------------------------ // ------------------------------ // --------------------- // Create notification // --------------------- MBeanServerNotification notif = new MBeanServerNotification( NotifType,MBeanServerDelegate.DELEGATE_NAME,name); if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { MBEANSERVER_LOGGER.logp(Level.FINER,DefaultMBeanServerInterceptor.class.getName(),"sendNotification",NotifType + " " + name); } delegate.sendNotification(notif); }
private void destroyListeners() { checkNoLocks(); logger.debug("destroyListeners","starts"); try { removeNotificationListener(MBeanServerDelegate.DELEGATE_NAME,creationListener); } catch (Exception e) { logger.warning("remove listener from MBeanServer delegate",e); } Set<ObjectName> names = queryNames(null,broadcasterQuery); for (final ObjectName name : names) { if (logger.debugOn()) logger.debug("destroyListeners","remove listener from " + name); removeBufferListener(name); } logger.debug("destroyListeners","ends"); }
protected void removeListenerForMBeanRemovednotif(Integer id) throws IOException,InstanceNotFoundException,ListenerNotFoundException { try { connection.removeNotificationListeners( MBeanServerDelegate.DELEGATE_NAME,new Integer[] {id},null); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); connection.removeNotificationListeners( MBeanServerDelegate.DELEGATE_NAME,null); } }
/** * Creates a DefaultMBeanServerInterceptor with the specified * repository instance. * <p>Do not forget to call <code>initialize(outer,Repository repository) { if (outer == null) throw new IllegalArgumentException("outer MBeanServer cannot be null"); if (delegate == null) throw new IllegalArgumentException("MBeanServerDelegate cannot be null"); if (instantiator == null) throw new IllegalArgumentException("MBeanInstantiator cannot be null"); if (repository == null) throw new IllegalArgumentException("Repository cannot be null"); this.server = outer; this.delegate = delegate; this.instantiator = instantiator; this.repository = repository; this.domain = repository.getDefaultDomain(); }
/** * Sends an MBeanServerNotifications with the specified type for the * MBean with the specified ObjectName */ private void sendNotification(String NotifType,NotifType + " " + name); } delegate.sendNotification(notif); }
private void destroyListeners() { checkNoLocks(); logger.debug("destroyListeners","ends"); }
protected void removeListenerForMBeanRemovednotif(Integer id) throws IOException,null); } }
public static void main(String[] args) throws Exception { System.out.println( "Test that <MBeanServerDelegate.DELEGATE_NAME> equals " + "<new ObjectName(\"JMImplementation:type=MBeanServerDelegate\")>"); final ObjectName delegateName = new ObjectName("JMImplementation:type=MBeanServerDelegate"); if (!delegateName.equals(MBeanServerDelegate.DELEGATE_NAME)) throw new AssertionError("Unexpected value: " + "MBeanServerDelegate.DELEGATE_NAME = " + MBeanServerDelegate.DELEGATE_NAME); System.out.println("MBeanServerDelegate.DELEGATE_NAME = " + "new ObjectName(\"" + delegateName + "\")"); System.out.println("Test that <ObjectName.WILDCARD> " + "equals <new ObjectName(\"*:*\")>"); final ObjectName wildcardName = new ObjectName("*:*"); if (!wildcardName.equals(ObjectName.WILDCARD)) throw new AssertionError("Unexpected value: " + "ObjectName.WILDCARD = " + ObjectName.WILDCARD); System.out.println("ObjectName.WILDCARD = " + "new ObjectName(\"" + wildcardName + "\")"); System.out.println("Test passes: constants were initialized properly"); }
protected void removeListenerForMBeanRemovednotif(Integer id) throws IOException,null); } }
/** * Creates a DefaultMBeanServerInterceptor with the specified * repository instance. * <p>Do not forget to call <code>initialize(outer,Repository repository) { if (outer == null) throw new IllegalArgumentException("outer MBeanServer cannot be null"); if (delegate == null) throw new IllegalArgumentException("MBeanServerDelegate cannot be null"); if (instantiator == null) throw new IllegalArgumentException("MBeanInstantiator cannot be null"); if (repository == null) throw new IllegalArgumentException("Repository cannot be null"); this.server = outer; this.delegate = delegate; this.instantiator = instantiator; this.repository = repository; this.domain = repository.getDefaultDomain(); }
/** * Sends an MBeanServerNotifications with the specified type for the * MBean with the specified ObjectName */ private void sendNotification(String NotifType,name); if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { MBEANSERVER_LOGGER.log(Level.TRACE,NotifType + " " + name); } delegate.sendNotification(notif); }
private void destroyListeners() { checkNoLocks(); logger.debug("destroyListeners","ends"); }
public static void main(String[] args) throws Exception { System.out.println( "Test that <MBeanServerDelegate.DELEGATE_NAME> equals " + "<new ObjectName(\"JMImplementation:type=MBeanServerDelegate\")>"); final ObjectName delegateName = new ObjectName("JMImplementation:type=MBeanServerDelegate"); if (!delegateName.equals(MBeanServerDelegate.DELEGATE_NAME)) throw new AssertionError("Unexpected value: " + "MBeanServerDelegate.DELEGATE_NAME = " + MBeanServerDelegate.DELEGATE_NAME); System.out.println("MBeanServerDelegate.DELEGATE_NAME = " + "new ObjectName(\"" + delegateName + "\")"); System.out.println("Test that <ObjectName.WILDCARD> " + "equals <new ObjectName(\"*:*\")>"); final ObjectName wildcardName = new ObjectName("*:*"); if (!wildcardName.equals(ObjectName.WILDCARD)) throw new AssertionError("Unexpected value: " + "ObjectName.WILDCARD = " + ObjectName.WILDCARD); System.out.println("ObjectName.WILDCARD = " + "new ObjectName(\"" + wildcardName + "\")"); System.out.println("Test passes: constants were initialized properly"); }
/** * Creates a DefaultMBeanServerInterceptor with the specified * repository instance. * <p>Do not forget to call <code>initialize(outer,Repository repository) { if (outer == null) throw new IllegalArgumentException("outer MBeanServer cannot be null"); if (delegate == null) throw new IllegalArgumentException("MBeanServerDelegate cannot be null"); if (instantiator == null) throw new IllegalArgumentException("MBeanInstantiator cannot be null"); if (repository == null) throw new IllegalArgumentException("Repository cannot be null"); this.server = outer; this.delegate = delegate; this.instantiator = instantiator; this.repository = repository; this.domain = repository.getDefaultDomain(); }
/** * Sends an MBeanServerNotifications with the specified type for the * MBean with the specified ObjectName */ private void sendNotification(String NotifType,NotifType + " " + name); } delegate.sendNotification(notif); }
private void destroyListeners() { checkNoLocks(); logger.debug("destroyListeners","ends"); }
protected void removeListenerForMBeanRemovednotif(Integer id) throws IOException,null); } }
public static void main(String[] args) throws Exception { System.out.println( "Test that <MBeanServerDelegate.DELEGATE_NAME> equals " + "<new ObjectName(\"JMImplementation:type=MBeanServerDelegate\")>"); final ObjectName delegateName = new ObjectName("JMImplementation:type=MBeanServerDelegate"); if (!delegateName.equals(MBeanServerDelegate.DELEGATE_NAME)) throw new AssertionError("Unexpected value: " + "MBeanServerDelegate.DELEGATE_NAME = " + MBeanServerDelegate.DELEGATE_NAME); System.out.println("MBeanServerDelegate.DELEGATE_NAME = " + "new ObjectName(\"" + delegateName + "\")"); System.out.println("Test that <ObjectName.WILDCARD> " + "equals <new ObjectName(\"*:*\")>"); final ObjectName wildcardName = new ObjectName("*:*"); if (!wildcardName.equals(ObjectName.WILDCARD)) throw new AssertionError("Unexpected value: " + "ObjectName.WILDCARD = " + ObjectName.WILDCARD); System.out.println("ObjectName.WILDCARD = " + "new ObjectName(\"" + wildcardName + "\")"); System.out.println("Test passes: constants were initialized properly"); }
protected void removeListenerForMBeanRemovednotif(Integer id) throws IOException,null); } }
/** * Creates a DefaultMBeanServerInterceptor with the specified * repository instance. * <p>Do not forget to call <code>initialize(outer,Repository repository) { if (outer == null) throw new IllegalArgumentException("outer MBeanServer cannot be null"); if (delegate == null) throw new IllegalArgumentException("MBeanServerDelegate cannot be null"); if (instantiator == null) throw new IllegalArgumentException("MBeanInstantiator cannot be null"); if (repository == null) throw new IllegalArgumentException("Repository cannot be null"); this.server = outer; this.delegate = delegate; this.instantiator = instantiator; this.repository = repository; this.domain = repository.getDefaultDomain(); }
/** * Sends an MBeanServerNotifications with the specified type for the * MBean with the specified ObjectName */ private void sendNotification(String NotifType,NotifType + " " + name); } delegate.sendNotification(notif); }
private void destroyListeners() { checkNoLocks(); logger.debug("destroyListeners","ends"); }
protected void removeListenerForMBeanRemovednotif(Integer id) throws IOException,null); } }
public static void main(String[] args) throws Exception { System.out.println( "Test that <MBeanServerDelegate.DELEGATE_NAME> equals " + "<new ObjectName(\"JMImplementation:type=MBeanServerDelegate\")>"); final ObjectName delegateName = new ObjectName("JMImplementation:type=MBeanServerDelegate"); if (!delegateName.equals(MBeanServerDelegate.DELEGATE_NAME)) throw new AssertionError("Unexpected value: " + "MBeanServerDelegate.DELEGATE_NAME = " + MBeanServerDelegate.DELEGATE_NAME); System.out.println("MBeanServerDelegate.DELEGATE_NAME = " + "new ObjectName(\"" + delegateName + "\")"); System.out.println("Test that <ObjectName.WILDCARD> " + "equals <new ObjectName(\"*:*\")>"); final ObjectName wildcardName = new ObjectName("*:*"); if (!wildcardName.equals(ObjectName.WILDCARD)) throw new AssertionError("Unexpected value: " + "ObjectName.WILDCARD = " + ObjectName.WILDCARD); System.out.println("ObjectName.WILDCARD = " + "new ObjectName(\"" + wildcardName + "\")"); System.out.println("Test passes: constants were initialized properly"); }
/** * Creates a DefaultMBeanServerInterceptor with the specified * repository instance. * <p>Do not forget to call <code>initialize(outer,Repository repository) { if (outer == null) throw new IllegalArgumentException("outer MBeanServer cannot be null"); if (delegate == null) throw new IllegalArgumentException("MBeanServerDelegate cannot be null"); if (instantiator == null) throw new IllegalArgumentException("MBeanInstantiator cannot be null"); if (repository == null) throw new IllegalArgumentException("Repository cannot be null"); this.server = outer; this.delegate = delegate; this.instantiator = instantiator; this.repository = repository; this.domain = repository.getDefaultDomain(); }
/** * Sends an MBeanServerNotifications with the specified type for the * MBean with the specified ObjectName */ private void sendNotification(String NotifType,NotifType + " " + name); } delegate.sendNotification(notif); }
private void destroyListeners() { checkNoLocks(); logger.debug("destroyListeners","ends"); }
protected void removeListenerForMBeanRemovednotif(Integer id) throws IOException,null); } }
public static void main(String[] args) throws Exception { System.out.println( "Test that <MBeanServerDelegate.DELEGATE_NAME> equals " + "<new ObjectName(\"JMImplementation:type=MBeanServerDelegate\")>"); final ObjectName delegateName = new ObjectName("JMImplementation:type=MBeanServerDelegate"); if (!delegateName.equals(MBeanServerDelegate.DELEGATE_NAME)) throw new AssertionError("Unexpected value: " + "MBeanServerDelegate.DELEGATE_NAME = " + MBeanServerDelegate.DELEGATE_NAME); System.out.println("MBeanServerDelegate.DELEGATE_NAME = " + "new ObjectName(\"" + delegateName + "\")"); System.out.println("Test that <ObjectName.WILDCARD> " + "equals <new ObjectName(\"*:*\")>"); final ObjectName wildcardName = new ObjectName("*:*"); if (!wildcardName.equals(ObjectName.WILDCARD)) throw new AssertionError("Unexpected value: " + "ObjectName.WILDCARD = " + ObjectName.WILDCARD); System.out.println("ObjectName.WILDCARD = " + "new ObjectName(\"" + wildcardName + "\")"); System.out.println("Test passes: constants were initialized properly"); }
/** * Creates a DefaultMBeanServerInterceptor with the specified * repository instance. * <p>Do not forget to call <code>initialize(outer,Repository repository) { if (outer == null) throw new IllegalArgumentException("outer MBeanServer cannot be null"); if (delegate == null) throw new IllegalArgumentException("MBeanServerDelegate cannot be null"); if (instantiator == null) throw new IllegalArgumentException("MBeanInstantiator cannot be null"); if (repository == null) throw new IllegalArgumentException("Repository cannot be null"); this.server = outer; this.delegate = delegate; this.instantiator = instantiator; this.repository = repository; this.domain = repository.getDefaultDomain(); }
/** * Sends an MBeanServerNotifications with the specified type for the * MBean with the specified ObjectName */ private void sendNotification(String NotifType,NotifType + " " + name); } delegate.sendNotification(notif); }
private void destroyListeners() { checkNoLocks(); logger.debug("destroyListeners","ends"); }
protected void removeListenerForMBeanRemovednotif(Integer id) throws IOException,null); } }
public static void main(String[] args) throws Exception { System.out.println( "Test that <MBeanServerDelegate.DELEGATE_NAME> equals " + "<new ObjectName(\"JMImplementation:type=MBeanServerDelegate\")>"); final ObjectName delegateName = new ObjectName("JMImplementation:type=MBeanServerDelegate"); if (!delegateName.equals(MBeanServerDelegate.DELEGATE_NAME)) throw new AssertionError("Unexpected value: " + "MBeanServerDelegate.DELEGATE_NAME = " + MBeanServerDelegate.DELEGATE_NAME); System.out.println("MBeanServerDelegate.DELEGATE_NAME = " + "new ObjectName(\"" + delegateName + "\")"); System.out.println("Test that <ObjectName.WILDCARD> " + "equals <new ObjectName(\"*:*\")>"); final ObjectName wildcardName = new ObjectName("*:*"); if (!wildcardName.equals(ObjectName.WILDCARD)) throw new AssertionError("Unexpected value: " + "ObjectName.WILDCARD = " + ObjectName.WILDCARD); System.out.println("ObjectName.WILDCARD = " + "new ObjectName(\"" + wildcardName + "\")"); System.out.println("Test passes: constants were initialized properly"); }
/** * Creates a DefaultMBeanServerInterceptor with the specified * repository instance. * <p>Do not forget to call <code>initialize(outer,Repository repository) { if (outer == null) throw new IllegalArgumentException("outer MBeanServer cannot be null"); if (delegate == null) throw new IllegalArgumentException("MBeanServerDelegate cannot be null"); if (instantiator == null) throw new IllegalArgumentException("MBeanInstantiator cannot be null"); if (repository == null) throw new IllegalArgumentException("Repository cannot be null"); this.server = outer; this.delegate = delegate; this.instantiator = instantiator; this.repository = repository; this.domain = repository.getDefaultDomain(); }
/** * Sends an MBeanServerNotifications with the specified type for the * MBean with the specified ObjectName */ private void sendNotification(String NotifType,NotifType + " " + name); } delegate.sendNotification(notif); }
private void destroyListeners() { checkNoLocks(); logger.debug("destroyListeners","ends"); }
protected void removeListenerForMBeanRemovednotif(Integer id) throws IOException,null); } }
public static void main(String[] args) throws Exception { System.out.println( "Test that <MBeanServerDelegate.DELEGATE_NAME> equals " + "<new ObjectName(\"JMImplementation:type=MBeanServerDelegate\")>"); final ObjectName delegateName = new ObjectName("JMImplementation:type=MBeanServerDelegate"); if (!delegateName.equals(MBeanServerDelegate.DELEGATE_NAME)) throw new AssertionError("Unexpected value: " + "MBeanServerDelegate.DELEGATE_NAME = " + MBeanServerDelegate.DELEGATE_NAME); System.out.println("MBeanServerDelegate.DELEGATE_NAME = " + "new ObjectName(\"" + delegateName + "\")"); System.out.println("Test that <ObjectName.WILDCARD> " + "equals <new ObjectName(\"*:*\")>"); final ObjectName wildcardName = new ObjectName("*:*"); if (!wildcardName.equals(ObjectName.WILDCARD)) throw new AssertionError("Unexpected value: " + "ObjectName.WILDCARD = " + ObjectName.WILDCARD); System.out.println("ObjectName.WILDCARD = " + "new ObjectName(\"" + wildcardName + "\")"); System.out.println("Test passes: constants were initialized properly"); }
javax.persistence.AttributeOverride的实例源码
/** * @param mergeWithAnnotations Whether to use Java annotations for this * element,if present and not disabled by the XMLContext defaults. * In some contexts (such as an association mapping) merging with * annotations is never allowed. */ private AttributeOverrides mergeAttributeOverrides(XMLContext.Default defaults,List<AttributeOverride> attributes,boolean mergeWithAnnotations) { if ( mergeWithAnnotations && defaults.canUseJavaAnnotations() ) { AttributeOverride annotation = getPhysicalAnnotation( AttributeOverride.class ); addAttributeOverrideIfNeeded( annotation,attributes ); AttributeOverrides annotations = getPhysicalAnnotation( AttributeOverrides.class ); if ( annotations != null ) { for ( AttributeOverride current : annotations.value() ) { addAttributeOverrideIfNeeded( current,attributes ); } } } if ( attributes.size() > 0 ) { AnnotationDescriptor ad = new AnnotationDescriptor( AttributeOverrides.class ); ad.setValue( "value",attributes.toArray( new AttributeOverride[attributes.size()] ) ); return AnnotationFactory.create( ad ); } else { return null; } }
private List<AttributeOverride> buildAttributeOverrides(List<Element> subelements,String nodeName) { List<AttributeOverride> overrides = new ArrayList<AttributeOverride>(); if ( subelements != null && subelements.size() > 0 ) { for ( Element current : subelements ) { if ( !current.getName().equals( nodeName ) ) { continue; } AnnotationDescriptor override = new AnnotationDescriptor( AttributeOverride.class ); copyStringAttribute( override,current,"name",true ); Element column = current.element( "column" ); override.setValue( "column",getColumn( column,true,current ) ); overrides.add( (AttributeOverride) AnnotationFactory.create( override ) ); } } return overrides; }
public static final AttributeOverride[] getAttributeOverrides(final AnnotatedElement ae) { AttributeOverride[] overrides = null; final AttributeOverrides aos = ae.getAnnotation(AttributeOverrides.class); if (aos != null) { overrides = aos.value(); } if (overrides == null || overrides.length == 0) { final AttributeOverride override = ae.getAnnotation(AttributeOverride.class); if (override != null) { overrides = new AttributeOverride[1]; overrides[0] = override; } else { overrides = new AttributeOverride[0]; } } return overrides; }
@DB() protected String buildSelectByIdsql(final StringBuilder sql) { if (_idField == null) { return null; } if (_idField.getAnnotation(EmbeddedId.class) == null) { sql.append(_table).append(".").append(DbUtil.getColumnName(_idField,null)).append(" = ? "); } else { final Class<?> clazz = _idField.getClass(); final AttributeOverride[] overrides = DbUtil.getAttributeOverrides(_idField); for (final Field field : clazz.getDeclaredFields()) { sql.append(_table).append(".").append(DbUtil.getColumnName(field,overrides)).append(" = ? AND "); } sql.delete(sql.length() - 4,sql.length()); } return sql.toString(); }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "RTableCatalog",column = @Column(name = "r_table_catalog")),@AttributeOverride(name = "RTableSchema",column = @Column(name = "r_table_schema")),@AttributeOverride(name = "RTableName",column = @Column(name = "r_table_name")),@AttributeOverride(name = "RRasterColumn",column = @Column(name = "r_raster_column")),@AttributeOverride(name = "srid",column = @Column(name = "srid")),@AttributeOverride(name = "scaleX",column = @Column(name = "scale_x",precision = 17,scale = 17)),@AttributeOverride(name = "scaleY",column = @Column(name = "scale_y",@AttributeOverride(name = "blocksizeX",column = @Column(name = "blocksize_x")),@AttributeOverride(name = "blocksizeY",column = @Column(name = "blocksize_y")),@AttributeOverride(name = "sameAlignment",column = @Column(name = "same_alignment")),@AttributeOverride(name = "regularBlocking",column = @Column(name = "regular_blocking")),@AttributeOverride(name = "numBands",column = @Column(name = "num_bands")),@AttributeOverride(name = "pixelTypes",column = @Column(name = "pixel_types")),@AttributeOverride(name = "nodataValues",column = @Column(name = "nodata_values")),@AttributeOverride(name = "outDb",column = @Column(name = "out_db")),@AttributeOverride(name = "extent",column = @Column(name = "extent")) }) public RasterColumnsId getId() { return this.id; }
private static Column getAttributeOverride(Class<?> type,String name) { AttributeOverride ao = type.getAnnotation(AttributeOverride.class); if (ao != null) { if (ao.name().equals(name)) { return ao.column(); } } AttributeOverrides aos = type.getAnnotation(AttributeOverrides.class); if (aos != null) { for (AttributeOverride a : aos.value()) { if (a.name().equals(name)) { return a.column(); } } } return null; }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "skuItem",column = @Column(name = "SKU_Item",length = 13)),@AttributeOverride(name = "upc",column = @Column(name = "UPC",length = 12)),@AttributeOverride(name = "sku",column = @Column(name = "SKU",length = 6)),@AttributeOverride(name = "itemNumber",column = @Column(name = "Item_Number",@AttributeOverride(name = "brand",column = @Column(name = "Brand",nullable = false,length = 45)),@AttributeOverride(name = "style",column = @Column(name = "Style",@AttributeOverride(name = "colorMap",column = @Column(name = "Color_Map",@AttributeOverride(name = "color",column = @Column(name = "Color",@AttributeOverride(name = "sizeMap",column = @Column(name = "Size_Map",@AttributeOverride(name = "size",column = @Column(name = "Size",@AttributeOverride(name = "sortSize",column = @Column(name = "Sort_Size",nullable = false)),@AttributeOverride(name = "inStock",column = @Column(name = "In_Stock",precision = 23,scale = 0)),@AttributeOverride(name = "material",column = @Column(name = "Material",@AttributeOverride(name = "shoeType",column = @Column(name = "Shoe_Type",length = 4)),@AttributeOverride(name = "description",column = @Column(name = "Description",length = 11)) }) public SkuShoeViewId getId() { return this.id; }
public static final AttributeOverride[] getAttributeOverrides(AnnotatedElement ae) { AttributeOverride[] overrides = null; AttributeOverrides aos = ae.getAnnotation(AttributeOverrides.class); if (aos != null) { overrides = aos.value(); } if (overrides == null || overrides.length == 0) { AttributeOverride override = ae.getAnnotation(AttributeOverride.class); if (override != null) { overrides = new AttributeOverride[1]; overrides[0] = override; } else { overrides = new AttributeOverride[0]; } } return overrides; }
@DB() protected String buildSelectByIdsql(final StringBuilder sql) { if (_idField == null) { return null; } if (_idField.getAnnotation(EmbeddedId.class) == null) { sql.append(_table).append(".").append(DbUtil.getColumnName(_idField,sql.length()); } return sql.toString(); }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "customerNumber",column = @Column(name = "customerNumber",@AttributeOverride(name = "checkNumber",column = @Column(name = "checkNumber",length = 50)) }) public PaymentId getId() { return this.id; }
private static Map<String,Column[]> buildColumnOverride(XAnnotatedElement element,String path) { Map<String,Column[]> columnOverride = new HashMap<String,Column[]>(); if ( element == null ) return columnOverride; AttributeOverride singleOverride = element.getAnnotation( AttributeOverride.class ); AttributeOverrides multipleOverrides = element.getAnnotation( AttributeOverrides.class ); AttributeOverride[] overrides; if ( singleOverride != null ) { overrides = new AttributeOverride[] { singleOverride }; } else if ( multipleOverrides != null ) { overrides = multipleOverrides.value(); } else { overrides = null; } //fill overridden columns if ( overrides != null ) { for (AttributeOverride depAttr : overrides) { columnOverride.put( StringHelper.qualify( path,depAttr.name() ),new Column[] { depAttr.column() } ); } } return columnOverride; }
/** * As per sections 12.2.3.23.9,12.2.4.8.9 and 12.2.5.3.6 of the JPA 2.0 * specification,the element-collection subelement completely overrides the * mapping for the specified field or property. Thus,any methods which * might in some contexts merge with annotations must not do so in this * context. */ private void getElementCollection(List<Annotation> annotationList,XMLContext.Default defaults) { for ( Element element : elementsForProperty ) { if ( "element-collection".equals( element.getName() ) ) { AnnotationDescriptor ad = new AnnotationDescriptor( ElementCollection.class ); addTargetClass( element,ad,"target-class",defaults ); getFetchType( ad,element ); getorderBy( annotationList,element ); getorderColumn( annotationList,element ); getMapKey( annotationList,element ); getMapKeyClass( annotationList,element,defaults ); getMapKeyTemporal( annotationList,element ); getMapKeyEnumerated( annotationList,element ); getMapKeyColumn( annotationList,element ); buildMapKeyJoinColumns( annotationList,element ); Annotation annotation = getColumn( element.element( "column" ),false,element ); addIfNotNull( annotationList,annotation ); getTemporal( annotationList,element ); getEnumerated( annotationList,element ); getLob( annotationList,element ); //Both map-key-attribute-overrides and attribute-overrides //translate into AttributeOverride annotations,which need //need to be wrapped in the same AttributeOverrides annotation. List<AttributeOverride> attributes = new ArrayList<AttributeOverride>(); attributes.addAll( buildAttributeOverrides( element,"map-key-attribute-override" ) ); attributes.addAll( buildAttributeOverrides( element,"attribute-override" ) ); annotation = mergeAttributeOverrides( defaults,attributes,false ); addIfNotNull( annotationList,annotation ); annotation = getAssociationOverrides( element,defaults,annotation ); getCollectionTable( annotationList,defaults ); annotationList.add( AnnotationFactory.create( ad ) ); getAccesstype( annotationList,element ); } } }
private void addAttributeOverrideIfNeeded(AttributeOverride annotation,List<AttributeOverride> overrides) { if ( annotation != null ) { String overrideName = annotation.name(); boolean present = false; for ( AttributeOverride current : overrides ) { if ( current.name().equals( overrideName ) ) { present = true; break; } } if ( !present ) { overrides.add( annotation ); } } }
public static String getColumnName(final Field field,final AttributeOverride[] overrides) { if (overrides != null) { for (final AttributeOverride override : overrides) { if (override.name().equals(field.getName())) { return override.column().name(); } } } assert (field.getAnnotation(Embedded.class) == null) : "Cannot get column name from embedded field: " + field.getName(); final Column column = field.getAnnotation(Column.class); return column != null ? column.name() : field.getName(); }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "refIdRecord1",column = @Column(name = "ref_id_record_1",@AttributeOverride(name = "refIdRecord2",column = @Column(name = "ref_id_record_2",@AttributeOverride(name = "refIdRelationType",column = @Column(name = "ref_id_relation_type",nullable = false)) }) public RelationsId getId() { return this.id; }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "fkIdAccount",column = @Column(name = "fk_id_account",@AttributeOverride(name = "fkIdAuthorities",column = @Column(name = "fk_id_authorities",nullable = false)) }) public UserAuthoritiesId getId() { return this.id; }
@Embedded @AttributeOverrides({ @AttributeOverride(name = "learner",column = @Column(name = "duration_learner")),@AttributeOverride(name = "eqOracle",column = @Column(name = "duration_eqOracle")) }) public DetailedStatistics getDuration() { return duration; }
@Embedded @AttributeOverrides({ @AttributeOverride(name = "learner",column = @Column(name = "mqs_learner")),column = @Column(name = "mqs_eqOracle")) }) public DetailedStatistics getMqsUsed() { return mqsUsed; }
@Embedded @AttributeOverrides({ @AttributeOverride(name = "learner",column = @Column(name = "symbolsUsed_learner")),column = @Column(name = "symbolsUsed_eqOracle")) }) public DetailedStatistics getSymbolsUsed() { return symbolsUsed; }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "studentId",column = @Column(name = "STUDENT_ID",precision = 5,@AttributeOverride(name = "classesId",column = @Column(name = "CLASSES_ID",precision = 4,@AttributeOverride(name = "status",column = @Column(name = "STU_CLASSES_STATUS",length = 1)) }) public StudentClassesId getId() { return this.id; }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "unitId",column = @Column(name = "unit_id",@AttributeOverride(name = "operationalPeriodId",column = @Column(name = "operational_period_id",nullable = false)) }) public AssignmentId getId() { return this.id; }
@Override public void evaluate(Method method,EvaluatorChain chain) { if (method.isAnnotationPresent(EmbeddedId.class)) { Map<String,AttributeOverride> overrides = getAttributeOverrides(method); Class<?> embeddedClz = method.getReturnType(); BeanInfo info = null; try { info = Introspector.getBeanInfo(embeddedClz); } catch (IntrospectionException e) { throw new RuntimeException(e); } for (String propertyName : overrides.keySet()) { for (PropertyDescriptor propDesc : info.getPropertyDescriptors()) { if (propDesc.getName().equals(propertyName)) { copyAttribute attribute = new copyAttribute(); attribute.getmethods().add(method); attribute.getmethods().add(propDesc.getReadMethod()); attribute.setColumnName(overrides.get(propertyName).column().name()); chain.add(attribute); break; } } } } else { chain.doNext(); } }
@Override public void evaluate(Method method,EvaluatorChain chain) { if (method.getReturnType().isAnnotationPresent(Embeddable.class) && !method.isAnnotationPresent(Transient.class)) { Map<String,AttributeOverride> overrides = getAttributeOverrides(method); Class<?> embeddedClz = method.getReturnType(); for (Method embeddedMethod : Arrays.stream(embeddedClz.getmethods()) // .filter(it -> it.isAnnotationPresent(Column.class)) // .collect(toList())) { String name = getPropertyName(embeddedMethod); String columnName = null; if (overrides.containsKey(name)) { columnName = overrides.get(name).column().name(); } else { columnName = embeddedMethod.getAnnotation(Column.class).name(); } copyAttribute attribute = new copyAttribute(); attribute.getmethods().add(method); attribute.getmethods().add(embeddedMethod); attribute.setColumnName(columnName); chain.add(attribute); } } else { chain.doNext(); } }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "name",column = @Column(name = "name",@AttributeOverride(name = "position",column = @Column(name = "position",nullable = false)) }) public PlanetId getId() { return id; }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "playersIdplayers",column = @Column(name = "players_idplayers",@AttributeOverride(name = "insurancesIdinsurances",column = @Column(name = "insurances_idinsurances",nullable = false)) }) public PlayersHasInsurancesId getId() { return this.id; }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "playersHasQuestsPlayersIdplayers",column = @Column(name = "players_has_quests_players_idplayers",@AttributeOverride(name = "playersHasQuestsQuestsIdquests",column = @Column(name = "players_has_quests_quests_idquests",@AttributeOverride(name = "placesHasTransportsPlacesOrigin",column = @Column(name = "places_has_transports_places_origin",@AttributeOverride(name = "placesHasTransportsTransportation",column = @Column(name = "places_has_transports_transportation",@AttributeOverride(name = "placesHasTransportsPlacesDestination",column = @Column(name = "places_has_transports_places_destination",nullable = false)) }) public TurnsHistoryId getId() { return this.id; }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "insurancesIdinsurances",@AttributeOverride(name = "risksIdrisks",column = @Column(name = "risks_idrisks",nullable = false)) }) public InsurancesHasTransportationrisksId getId() { return this.id; }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "playersHasQuestsPlayersIdplayers",nullable = false)) }) public QuestInsurancesId getId() { return this.id; }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "placesOrigin",column = @Column(name = "places_origin",@AttributeOverride(name = "transportation",column = @Column(name = "transportation",@AttributeOverride(name = "placesDestination",column = @Column(name = "places_destination",nullable = false)) }) public PlacesHasTransportsId getId() { return this.id; }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "turnsHistoryPlayersHasQuestsPlayersIdplayers",column = @Column(name = "turns_history_players_has_quests_players_idplayers",@AttributeOverride(name = "turnsHistoryPlayersHasQuestsQuestsIdquests",column = @Column(name = "turns_history_players_has_quests_quests_idquests",@AttributeOverride(name = "turnsHistoryPlacesHasTransportsPlacesOrigin",column = @Column(name = "turns_history_places_has_transports_places_origin",@AttributeOverride(name = "turnsHistoryPlacesHasTransportsTransportation",column = @Column(name = "turns_history_places_has_transports_transportation",@AttributeOverride(name = "turnsHistoryPlacesHasTransportsPlacesDestination",column = @Column(name = "turns_history_places_has_transports_places_destination",@AttributeOverride(name = "transportationrisksIdrisks",column = @Column(name = "transportationrisks_idrisks",nullable = false)) }) public TurnsHistoryHasTransportationrisksId getId() { return this.id; }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "playersIdplayers",@AttributeOverride(name = "questsIdquests",column = @Column(name = "quests_idquests",nullable = false)) }) public PlayersHasQuestsId getId() { return this.id; }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "insurancesIdinsurances",@AttributeOverride(name = "placesrisksIdrisks",column = @Column(name = "placesrisks_idrisks",nullable = false)) }) public InsurancesHasPlacesrisksId getId() { return this.id; }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "turnsHistoryPlayersHasQuestsPlayersIdplayers",nullable = false)) }) public TurnsHistoryHasPlacesrisksId getId() { return this.id; }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "OTableCatalog",column = @Column(name = "o_table_catalog")),@AttributeOverride(name = "OTableSchema",column = @Column(name = "o_table_schema")),@AttributeOverride(name = "OTableName",column = @Column(name = "o_table_name")),@AttributeOverride(name = "ORasterColumn",column = @Column(name = "o_raster_column")),@AttributeOverride(name = "RTableCatalog",@AttributeOverride(name = "overviewFactor",column = @Column(name = "overview_factor")) }) public RasterOverviewsId getId() { return this.id; }
今天的关于java.beans.PersistenceDelegate的实例源码和java.beans.introspection的分享已经结束,谢谢您的关注,如果想了解更多关于android.arch.persistence.room.Delete的实例源码、java.beans.DefaultPersistenceDelegate的实例源码、javax.management.MBeanServerDelegate的实例源码、javax.persistence.AttributeOverride的实例源码的相关知识,请在本站进行查询。
本文标签: