[Design the new POJO MicroContainer] - Re: Merged ClassInfo annotation view?
by alesj
It depends.
If you have ControllerContext, then something like this:
| ControllerContext context = ...
| KernelMetaDataRepository repository = kernel.getMetaDataRepository();
| MetaData md = repository.getMetaData(context);
|
Or get a handle on MetaDataRepository.
| public interface MetaDataRepository
| {
| /**
| * Get the meta data for a scope key
| *
| * @param key the key
| * @return the meta data
| */
| MetaData getMetaData(ScopeKey key);
|
| /**
| * Get the meta data retrieval for a scope key
| *
| * @param key the key
| * @return the meta data
| */
| MetaDataRetrieval getMetaDataRetrieval(ScopeKey key);
|
| /**
| * Get the children of this scope
| *
| * @param key the key
| * @return the children
| */
| Set<ScopeKey> getChildren(ScopeKey key);
|
| /**
| * Visit each node
| *
| * @param visitor the visitor
| * @return the matching scopes
| */
| Set<ScopeKey> matchScopes(MetaDataRepositoryVisitor visitor);
| }
|
Where you then pull the MetaData out with the right ScopeKey.
Note: each deployment unit has MetaDataRepository as an attachment:
| if (repository != null)
| context.getTransientAttachments().addAttachment(MutableMetaDataRepository.class, repository);
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4185427#4185427
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4185427
14 years, 7 months
[Design of POJO Server] - Re: JBAS-6104; slow Seam deployments
by alesj
"alesj" wrote :
| I'll see if I can re-write this to use VFS directly.
I've implemented DU based Javassist ClassPath,
which does the trick by doing lookup directly on VFS.
| public class DeploymentUnitClassPath implements ClassPath
| {
| private VFSDeploymentUnit unit;
| private Map<String, VirtualFile> cache;
|
| public DeploymentUnitClassPath(VFSDeploymentUnit unit)
| {
| if (unit == null)
| throw new IllegalArgumentException("Null deployment unit.");
| this.unit = unit;
| this.cache = new HashMap<String, VirtualFile>();
| }
|
| /**
| * Find file.
| *
| * @param className the classname we're looking for
| * @return virtual file or null if not found
| * @throws IOException for any exception
| */
| protected VirtualFile findFile(String className) throws IOException
| {
| // ignore jdk classes
| if (ClassFilter.JAVA_ONLY.matchesClassName(className))
| return null;
|
| VirtualFile file = cache.get(className);
| if (file != null)
| return file;
|
| List<VirtualFile> classPath = unit.getClassPath();
| if (classPath != null && classPath.isEmpty() == false)
| {
| String path = ClassLoaderUtils.classNameToPath(className);
| for (VirtualFile cp : classPath)
| {
| file = cp.getChild(path);
| if (file != null)
| {
| cache.put(className, file);
| return file;
| }
| }
| }
|
| return null;
| }
|
| public InputStream openClassfile(String className) throws NotFoundException
| {
| try
| {
| VirtualFile file = findFile(className);
| if (file != null)
| return file.openStream();
| }
| catch (IOException e)
| {
| throw new NotFoundException("Exception finding file: " + className, e);
| }
| throw new NotFoundException("ClassName '" + className + "' not found in deployment unit: " + unit);
| }
|
| public URL find(String className)
| {
| try
| {
| VirtualFile file = findFile(className);
| if (file != null)
| return file.toURL();
| }
| catch (Exception ignored)
| {
| }
| return null;
| }
|
| public void close()
| {
| cache.clear();
| }
| }
It's in the deployers trunk.
Can either Stan or Shane test this?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4185387#4185387
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4185387
14 years, 7 months